// Code generated by bpf2go; DO NOT EDIT.
//go:build 386 || amd64 || amd64p32 || arm || arm64 || loong64 || mips64le || mips64p32le || mipsle || ppc64le || riscv64

package tracer

import (
	"bytes"
	_ "embed"
	"fmt"
	"io"

	"github.com/cilium/ebpf"
)

type mountsnoopEvent struct {
	Delta     uint64
	Flags     uint64
	Pid       uint32
	Tid       uint32
	MountNsId uint64
	Timestamp uint64
	Ret       int32
	Comm      [16]uint8
	Fs        [8]uint8
	Src       [4096]uint8
	Dest      [4096]uint8
	Data      [512]uint8
	Op        mountsnoopOp
}

type mountsnoopOp uint32

const (
	mountsnoopOpMOUNT  mountsnoopOp = 0
	mountsnoopOpUMOUNT mountsnoopOp = 1
)

// loadMountsnoop returns the embedded CollectionSpec for mountsnoop.
func loadMountsnoop() (*ebpf.CollectionSpec, error) {
	reader := bytes.NewReader(_MountsnoopBytes)
	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
	if err != nil {
		return nil, fmt.Errorf("can't load mountsnoop: %w", err)
	}

	return spec, err
}

// loadMountsnoopObjects loads mountsnoop and converts it into a struct.
//
// The following types are suitable as obj argument:
//
//	*mountsnoopObjects
//	*mountsnoopPrograms
//	*mountsnoopMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func loadMountsnoopObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
	spec, err := loadMountsnoop()
	if err != nil {
		return err
	}

	return spec.LoadAndAssign(obj, opts)
}

// mountsnoopSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type mountsnoopSpecs struct {
	mountsnoopProgramSpecs
	mountsnoopMapSpecs
}

// mountsnoopSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type mountsnoopProgramSpecs struct {
	IgMountE  *ebpf.ProgramSpec `ebpf:"ig_mount_e"`
	IgMountX  *ebpf.ProgramSpec `ebpf:"ig_mount_x"`
	IgUmountE *ebpf.ProgramSpec `ebpf:"ig_umount_e"`
	IgUmountX *ebpf.ProgramSpec `ebpf:"ig_umount_x"`
}

// mountsnoopMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type mountsnoopMapSpecs struct {
	Args                 *ebpf.MapSpec `ebpf:"args"`
	Events               *ebpf.MapSpec `ebpf:"events"`
	GadgetMntnsFilterMap *ebpf.MapSpec `ebpf:"gadget_mntns_filter_map"`
	Heap                 *ebpf.MapSpec `ebpf:"heap"`
}

// mountsnoopObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to loadMountsnoopObjects or ebpf.CollectionSpec.LoadAndAssign.
type mountsnoopObjects struct {
	mountsnoopPrograms
	mountsnoopMaps
}

func (o *mountsnoopObjects) Close() error {
	return _MountsnoopClose(
		&o.mountsnoopPrograms,
		&o.mountsnoopMaps,
	)
}

// mountsnoopMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to loadMountsnoopObjects or ebpf.CollectionSpec.LoadAndAssign.
type mountsnoopMaps struct {
	Args                 *ebpf.Map `ebpf:"args"`
	Events               *ebpf.Map `ebpf:"events"`
	GadgetMntnsFilterMap *ebpf.Map `ebpf:"gadget_mntns_filter_map"`
	Heap                 *ebpf.Map `ebpf:"heap"`
}

func (m *mountsnoopMaps) Close() error {
	return _MountsnoopClose(
		m.Args,
		m.Events,
		m.GadgetMntnsFilterMap,
		m.Heap,
	)
}

// mountsnoopPrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to loadMountsnoopObjects or ebpf.CollectionSpec.LoadAndAssign.
type mountsnoopPrograms struct {
	IgMountE  *ebpf.Program `ebpf:"ig_mount_e"`
	IgMountX  *ebpf.Program `ebpf:"ig_mount_x"`
	IgUmountE *ebpf.Program `ebpf:"ig_umount_e"`
	IgUmountX *ebpf.Program `ebpf:"ig_umount_x"`
}

func (p *mountsnoopPrograms) Close() error {
	return _MountsnoopClose(
		p.IgMountE,
		p.IgMountX,
		p.IgUmountE,
		p.IgUmountX,
	)
}

func _MountsnoopClose(closers ...io.Closer) error {
	for _, closer := range closers {
		if err := closer.Close(); err != nil {
			return err
		}
	}
	return nil
}

// Do not access this directly.
//
//go:embed mountsnoop_bpfel.o
var _MountsnoopBytes []byte
